package com.mdtx.base.log;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

/**
 * Manager日志输出
 *
 * @author zhgz
 * @create 2017-08-19 17:47
 **/
@Aspect
@Component
public class FrameManagerMonitor extends  AbstractFrameMonitor{

    private final  Logger log = LoggerFactory.getLogger(FrameManagerMonitor.class);

    @Override
    protected String hierarchy() {
        return MANAGER;
    }

    @Pointcut("execution(* com.mdtx.business.service..*.*(..))")
    public void managerMethodPointCut(){}


    @Before("managerMethodPointCut()")
    public void doBefore(JoinPoint joinPoint){
        doBefore(log,joinPoint.getSignature().getName());
        params(log,super.getParams(joinPoint.getArgs()));

    }

    @AfterReturning(returning = "ret",pointcut = "managerMethodPointCut()")
    public  void doBeforeReturn(Object ret){
        doBeforeReturn(log,ret);
    }



    @Around("managerMethodPointCut()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] obj = super.setAround(joinPoint);
        doAround(log,obj[1].toString());
        return obj[0];

    }
}
